import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:get/get.dart';
import 'package:sgy_flutter/gen/assets.gen.dart';
import 'package:sgy_flutter/page/dfu/logic.dart';
import 'package:sgy_flutter/widget/fading_circle.dart';

class UpdateView extends GetView<DfuLogic> {
  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Container(
          width: double.infinity,
        ),
        SizedBox(
          width: 170,
          height: 170,
          child: Stack(
            children: [
              FadingCircle(
                size: 170,
                color: Get.theme.primaryColor,
              ),
              Align(
                alignment: Alignment.center,
                child: Obx(() => Text(
                      "${controller.progress}",
                      style: TextStyle(
                          fontSize: 28, color: Get.theme.primaryColor),
                    )),
              ),
            ],
          ),
        ),
        Obx(
          () => Text(
            "${controller.dfuTaskName}",
            style: TextStyle(fontSize: 20, color: Color(0xff1e1e1e)),
          ),
        ).marginOnly(top: 32),
        Obx(
          () => Text(
            "${controller.dfuTaskState}",
            style: TextStyle(fontSize: 14, color: Color(0xff999999)),
          ),
        ).marginOnly(top: 10),
        Row(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Assets.image.iconWarning
                .image(width: 16, height: 16)
                .marginOnly(top: 2, right: 4),
            Expanded(child: Text(
              "升级过程中请勿关闭手机屏幕或将应用切入后台。".tr,
              style: TextStyle(
                fontWeight: FontWeight.normal,
                fontSize: 15,
                color: Color(0xff7a7a7a),
              ),
            )),
          ],
        ).marginOnly(top: 40, left: 12, right: 12),
      ],
    );
  }
}
